package crp.services.api.graphql.models;

import crp.core.academic.domain.models.AcademicYearEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.eclipse.microprofile.graphql.Type;

import javax.validation.constraints.NotNull;
import java.time.OffsetDateTime;

@Type("AcademicYear")
@Builder
@Getter
@AllArgsConstructor
public class AcademicYearPayload {

    @NotNull
    private final Integer year;
    private final OffsetDateTime startAt;
    private final OffsetDateTime endAt;

    public static AcademicYearPayload of(AcademicYearEntity entity) {
        return AcademicYearPayload.builder()
                .year(entity.getYear())
                .startAt(entity.getStartAt())
                .endAt(entity.getEndAt())
                .build();
    }
}
